'use strict';
module.exports = (app) => {
  // 用户表
  const { STRING, INTEGER, DATE, TEXT, DOUBLE } = app.Sequelize;
  const User = app.model.define('s_user', {
    id: { type: INTEGER, primaryKey: true, autoIncrement: true },
    token: {
      type: STRING,
      comment: 'token 检验是否登录',
    },
    project_id: {
      type: INTEGER,
      comment: '项目id',
    },
    visit_num: {
      type: INTEGER,
      comment: '访问次数',
      defaultValue: 0,
    },
    money: {
      type: DOUBLE,
      comment: '钱包余额',
      defaultValue: 0,
    },
    token_out_of_date: {
      type: STRING,
      comment: 'token 过期时间， 时间戳',
    },
    type: {
      type: STRING,
      comment: '1 用户，2商家',
      defaultValue: '1',
    },
    real_name: {
      type: STRING,
      comment: '真实名称',
      unique: true,
    },
    name: {
      type: STRING,
      comment: '昵称',
      unique: true,
      allowNull: false,
    },
    sex: {
      type: INTEGER,
      comment: '1 男,2女',
    },
    phone: {
      type: STRING,
      comment: '手机号码',
      allowNull: false,
    },
    password: {
      type: STRING,
      comment: '密码',
      allowNull: false,
    },
    birth_date: {
      type: DATE,
      comment: '出生日期',
    },
    header_img: {
      type: TEXT,
      comment: '头像',
    },
    openid: {
      type: STRING,
      comment: '微信openid',
    },
    wx_name: {
      type: STRING,
      comment: '微信昵称',
    },

    total_score: {
      type: INTEGER,
      comment: '总积分',
      defaultValue: 0,
    },
    remain_score: {
      type: INTEGER,
      comment: '剩余积分',
      defaultValue: 0,
    },
    use_score: {
      type: INTEGER,
      comment: '已使用积分',
      defaultValue: 0,
    },
    last_ip: {
      type: STRING,
      comment: '上次登陆ip地址',
      allowNull: true,
    },
  });

  return User;
};
